define(['app'],function (app) {
    app.controller('addPostCtrl', ['$scope','$ionicPopup', function($scope, $ionicPopup) {
        // Triggered on a button click, or some other target
        // $scope.addcomment = function() {
        //     $scope.data = {}
        //     var myPopup = $ionicPopup.show({
        //         template: '<input type="text" ng-model="data.comment">',
        //         title: '添加评论',
        //         scope: $scope,
        //         buttons: [
        //             { text: '取消' },
        //             {
        //                 text: '<b>保存</b>',
        //                 type: 'button-positive',
        //                 onTap: function(e) {
        //                     return $scope.data.comment;
        //                 }
        //             }
        //         ]
        //     });
        //     myPopup.then(function(res) {
        //         console.log('Tapped!', res);
        //     });
        // };
      /***
       * @param {string} cookieName Cookie名称
       * @param {string} cookieValue Cookie值
       * @param {number} nDays Cookie过期天数
       */
      function SetCookie(cookieName,cookieValue,nDays) {
        /*当前日期*/
        var today = new Date();
        /*Cookie过期时间*/
        var expire = new Date();
        /*如果未设置nDays参数或者nDays为0，取默认值1*/
        if(nDays == null || nDays == 0) nDays = 1;
        /*计算Cookie过期时间*/
        expire.setTime(today.getTime() + 3600000 * 24 * nDays);
        /*设置Cookie值*/
        document.cookie = cookieName + "=" + escape(cookieValue)
          + ";expires=" + expire.toGMTString();
      }
      $scope.issue = function () {
        /*是否选中7天内无需登录*/
        var content = $("content").value;
        if(content) {
          SetCookie("content",content,1);
          /*跳转到ex8.html页面*/
          document.location = "/#/tab/friend";
        } else {
          alert("内容不能为空！");
        }
      };

      function $(id) {
        return document.getElementById(id);
      }
    }]);

});
